package com.dongdongshop.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.dongdongshop.pojo.TbAreas;
import com.dongdongshop.pojo.TbCities;
import com.dongdongshop.pojo.TbProvinces;
import com.dongdongshop.service.AreaService;
import com.dongdongshop.service.CitiesService;
import com.dongdongshop.service.ProvincesService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Description
 * @ClassName IndexController
 * @Author RC
 * @date 2020.12.18 20:41
 */
@Controller
public class IndexController {
    @Reference(timeout = 100000,check = false)
    private ProvincesService provincesService;
    @Reference(timeout = 100000,check = false)
    private CitiesService citiesService;
    @Reference(timeout = 100000,check = false)
    private AreaService areaService;

    @RequestMapping({"index","/"})
    public String index(){
        return "index";

    }
//
    @RequestMapping("login")
    public String login(){
        return "login";
    }
    @RequestMapping("toLogin")
    public String toLogin(){
        return "login";
    }

    @RequestMapping("register")
    public String register(){
        return "register";
    }

    @RequestMapping("toGetOrderInfo")
    public String toGetOrderInfo(){
        return "getOrderInfo";
    }

    @RequestMapping("toHomeIndex")
    public String toHome(){
        return "home-index";
    }

    @RequestMapping("home-setting-address")
    public String toHomeSettingAddress(Model model){
        List<TbProvinces> provinces =  provincesService.getInfoAll();
        List<TbCities> citiesList =  citiesService.getInfoAll();
        List<TbAreas> areasList =  areaService.getInfoAll();
        model.addAttribute("provinces",provinces);
        model.addAttribute("citiesList",citiesList);
        model.addAttribute("areasList",areasList);
        return "home-setting-address";
    }
    /*退出登录*/
    @RequestMapping("logout")
    public String logout(HttpServletRequest request){
        request.getSession().removeAttribute("loginUser");
        return "index";
    }
    @RequestMapping({"cart"})
    public String cart(){
        return "cart";
    }
    //支付页面
    @RequestMapping({"pay"})
    public String pay(){
        return "pay";
    }

    @RequestMapping({"homeOrderPay"})
    public String homeOrderPay(){
        return "home-order-pay";
    }

    @RequestMapping({"homeOrderSend"})
    public String homeOrderSend(){
        return "home-order-send";
    }

    @RequestMapping({"homeOrderReceive"})
    public String homeOrderReceive(){
        return "home-order-receive";
    }

    @RequestMapping({"homeOrderEvaluate"})
    public String homeOrderEvaluate(){
        return "home-order-evaluate";
    }

    @RequestMapping({"JD-index"})
    public String JDIndex(){
        return "JD-index";
    }

    @RequestMapping({"pointsuccess"})
    public String pointsuccess(){
        return "pointsuccess.html";
    }
    @RequestMapping({"pointfail"})
    public String pointfail(){
        return "pointfail.html";
    }
    //秒杀
    @RequestMapping({"seckill-index"})
    public String seckillIndex(){
        return "seckill-index.html";
    }
    //es搜索
    @RequestMapping({"search"})
    public String search(){
        return "search.html";
    }

    @RequestMapping({"home-order-evaluate"})
    public String orderEvaluate(){
        return "home-order-evaluate.html";
    }

    @RequestMapping({"echarts"})
    public String echarts(){
        return "echarts.html";
    }



}
